Ext.onReady(function(){
	var tree_store = Ext.create('Ext.data.TreeStore', {
	    id:'tree_store',
	    proxy: {
	        type: 'ajax',
	        url: '../login/loginTree.do',
	        reader: {
	            type: 'json'
	        }
	    },
	    root: { expanded: true },//
	    autoLoad: true
	});
	
	var treePanel = Ext.create('Ext.tree.Panel', {
    //layout:'fit',
    stateId: 'navigation-panel',
    id: 'tree-panel',
    title: '拓扑结构',
    split: true,
    width: 200,
    height:300,
    minWidth: 175,
    maxWidth: 400,
    animCollapse: true,
    //rootVisible: false,  //默认不显示根节点
    //singleExpand: true, //
    //containerScroll:true,
    useArrows: true,
    store: tree_store,
    //root: {expanded: true},
    tools: [{
        type: 'refresh',
        tooltip: '刷新',
        // hidden:true,
        handler: function() {//Ext.data.Store load
            tree_store.load({
                scope: this,
                callback: function(records, operation, success) {
                    //Ext.Msg.alert('refresh success!');
                    treePanel.getRootNode().eachChild(function(child) { child.expand(); });
                }
            });
        }
    }
    ],
    collapsible: true,
    listeners: {
        'load' : function(){
            treePanel.expandAll();
        }, 

        'itemclick': function(view, record, item, index, e) {
            nodeId = record.raw.id; //获取点击的节点id
            nodeText = record.raw.text; //获取点击的节点text
            Ext.Msg.alert("提示信息", nodeId + nodeText);
            

        }
    }
});
treePanel.render("a");
})